const execSQL = require('../db/index')
const { formatHumpLineTransfer} = require('../utils/index')
const Router = require('koa-router')
const router = new Router()
//获取商品
router.get('/dictionary', async (ctx) => {
  //{a: '', goodsName: '', pageNum: '1', pageSize: '1'}
  let id = ctx.query.id || 0
  const data = await execSQL(`SELECT * FROM dictionary WHERE parent_id=${id}`)
  const list = data.map(item => {
    return formatHumpLineTransfer(item, 'hump')
  })
  
  ctx.body = {
    code: 200,
    data:{
      list
    }
  }
});
module.exports = router